/**
 * 
 */
package com.lanyou.esb.servicemix.monitor.rest;


import retrofit.http.Field;
import retrofit.http.FormUrlEncoded;
import retrofit.http.GET;
import retrofit.http.Multipart;
import retrofit.http.POST;
import retrofit.http.Part;
import retrofit.http.Path;
import retrofit.mime.TypedFile;
import retrofit.mime.TypedString;

import com.lanyou.esb.servicemix.monitor.rest.bean.ActionResponse;
import com.lanyou.esb.servicemix.monitor.rest.bean.BundleResponse;
import com.lanyou.esb.servicemix.monitor.rest.bean.LogResponse;
import com.lanyou.esb.servicemix.monitor.rest.bean.ServiceResponse;

/**
 * @author gonglei
 *
 */
public interface MonitorService {

	/**
	 * 查询系统当前装载的所有bundle列表
	 * @return
	 */
	@GET("/bundles.json")
	BundleResponse getBundles();

	/**
	 * 查询单个bundle的详细信息
	 * @param id
	 * @return
	 */
	@GET("/bundles/{id}.json")
	BundleResponse getBundleById(@Path("id") int id);

	/**
	 * 查询系统装载的所有的服务列表
	 * @return
	 */
	@GET("/services.json")
	ServiceResponse getServices();

	/**
	 * 查询单个服务的详细信息
	 * @param id
	 * @return
	 */
	@GET("/services/{id}.json")
	ServiceResponse getServiceById(@Path("id") int id);

	/**
	 * 安装bundle
	 * @param action 值必须为"install"
	 * @return
	 */
	@Multipart
	@POST("/bundles")
	String installBundle(@Part("action") TypedString action, @Part("bundlestart") TypedString bundlestart, @Part("bundlestartlevel") TypedString bundlestartlevel , @Part("bundlefile")
	TypedFile file) ;

	/**
	 * 安装bundle
	 * @param action 值必须为"install"
	 * @return
	 */
	@Multipart
	@POST("/bundles")
	String installBundle(@Part("action") TypedString action,  @Part("bundlestartlevel") TypedString bundlestartlevel , @Part("bundlefile")
	TypedFile file) ;
	
	/**
	 * 操作bundle
	 * @param id
	 * @param action 可选择为"start","stop","refresh","update","uninstall"
     */
	@FormUrlEncoded
	@POST("/bundles/{id}")
	ActionResponse executeBundle(@Path("id") int id,@Field("action") String action );

	/**
	 * 查询日志
	 * @param minLevel
	 * @return
     */
	@FormUrlEncoded
	@POST("/logs")
	LogResponse logs(@Field("minLevel") String minLevel);
}
